package com.xh.mapper;

import com.xh.pojo.Article;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 黄立恒
 * @version 1.0
 */
@Mapper
public interface ArticleMapper {

    //新增商品
    @Insert("insert into article(title,money,content,cover_img,state,category_id,create_user,create_time,update_time) " +
            "values(#{title},#{money},#{content},#{coverImg},#{state},#{categoryId},#{createUser},#{createTime},#{updateTime})")
    void add(Article article);


    //配置映射
    //按条件查询
    List<Article> list(Integer userId,Integer categoryId, String state, String sellstate);

    //更新商品
    @Update("update article set title=#{title},money=#{money},content=#{content},cover_img=#{coverImg}," +
            "update_time=#{updateTime},category_id=#{categoryId},sellstate=#{sellstate}  where id=#{id}")
    void update(Article article);

    //根据id查询商品信息
    @Select("select * from article where id = #{id}")
    Article findById(Integer id);

    //根据id删除商品信息
    @Delete("delete from article where id=#{id}")
    void deleteById(Integer id);
}
